﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace MediaGarden.Playlists.Services
{
    public abstract class PlaylistOutputFilter<TPlaylist> : IPlaylistOutputFilter
    {
        public void Playlist(PlaylistContext context)
        {
            if (context.Playlist is TPlaylist)
            {
                OnPlaylist(((TPlaylist)context.Playlist), context);
            }
        }

        protected abstract void OnPlaylist(TPlaylist playlist, PlaylistContext context);

        public abstract void PlaylistItem(MediaGarden.Models.IMediaItem source, object playlistItem, PlaylistContext context);
    }

    public abstract class PlaylistOutputFilter<TPlaylist, TItem> : PlaylistOutputFilter<TPlaylist>
    {
        public override void PlaylistItem(MediaGarden.Models.IMediaItem source, object playlistItem, PlaylistContext context)
        {
            if (context.Playlist is TPlaylist && playlistItem is TItem)
            {
                OnPlaylistItem(((TPlaylist)context.Playlist),source, ((TItem)playlistItem), context);
            }
        }

        protected abstract void OnPlaylistItem(TPlaylist playlist, Models.IMediaItem source, TItem playlistItem, PlaylistContext context);
    }

}